home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 241_01 / gettruth.ci < prev    next >
Text File  |  1987-08-29  |  2KB  |  94 lines

  1. /*
  2. HEADER:         CUG241;
  3. TITLE:          Inference Engine for Expert System;
  4. DATE:           12/30/85;
  5. VERSION:
  6. DESCRIPTION:   "Source code for inference engine for an Expert System.";
  7. KEYWORDS:       Artificial Intelligence, expert systems, inference engine;
  8. SYSTEM:         MS-DOS or UNIX System V;
  9. FILENAME:       GETTRUTH.C;
  10. WARNINGS:      "User-supported, non-commercial"
  11. AUTHORS:        George Hageman; 
  12. COMPILERS:      Microsoft C V3.00 or UNIX System V Portable C Compiler;
  13. REFERENCES:     ;
  14. ENDREF
  15. */
  16.  
  17.  
  18.  
  19. /*****************************************************************
  20. **                                **
  21. **      Inference -- (C) Copyright 1985 George Hageman    **
  22. **                                **
  23. **        user-supported software:                **
  24. **                                **
  25. **            George Hageman                **
  26. **            P.O. Box 11234                **
  27. **            Boulder, Colorado 80302            **
  28. **                                **
  29. *****************************************************************/
  30.  
  31. /*************************************************
  32. **
  33. **    getTruth(antecedent) 
  34. **
  35. **    asks user for the truth of a string or
  36. **    returns --
  37. **        TRUE if user says the statement is TRUE
  38. **        FALSE if the user says the statement is FALSE
  39. **
  40. *************************************************/
  41.  
  42. #include <stdio.h>
  43.  
  44. #ifdef MSDOS
  45. #include <conio.h>
  46. #endif
  47.  
  48. #include "expert.h"
  49. #include "inference.h"
  50.  
  51. int getTruth(cnsquent)
  52.     int    cnsquent ;
  53. {
  54. int done,c ;
  55. done = FALSE ;
  56.  
  57. while(!done)
  58.     {
  59.     printf("\n Is the following statement True?  (T/F,Y/N)\n\n ") ;
  60.     printf("%s    ?",&strBuff[ruleBuff[cnsquent].string]) ;
  61. #ifdef MSDOS
  62.     c = getche() ;
  63. #endif
  64. #ifdef UNIXSV
  65.     c = getchar() ;    
  66.     getchar() ;
  67. #endif
  68.     switch(c) 
  69.         {
  70.         case 'y' :
  71.         case 'Y' :
  72.         case 't' :
  73.         case 'T' :
  74.             printf("\n\n") ;
  75.             return(TRUE) ;
  76.         case 'n' :
  77.         case 'N' :
  78.         case 'f' :
  79.         case 'F' :
  80.             printf("\n\n") ;
  81.             return(FALSE) ;
  82.         case 'w' :
  83.         case 'W' :
  84.             printf("\n Why is not implemented \n") ;
  85.         default :
  86.             printf("\n Please try again \"T\" or \"F\" \n ") ;
  87.         }
  88.     }
  89. }
  90.  
  91.  
  92.  
  93.  
  94.